package util;

import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.Player;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

public class MusicPlayer extends Thread{
    private String musicName;
    //加载音乐
    public MusicPlayer(String fileName){
        this.musicName = fileName;
    }
    @Override
    public void run() {
        try {
            new Player(new BufferedInputStream(new FileInputStream(musicName))).play();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (JavaLayerException e) {
            e.printStackTrace();
        }
    }
}
